package in.co.codedoc.rpc;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import in.co.codedoc.cg.annotations.ExportedRPCMethod;
import in.co.codedoc.cg.annotations.ExportsRPCMethods;

@ExportsRPCMethods
public class RPCServiceLister
{
	@ExportedRPCMethod
	public static List<RPCServiceDescription> ListServices()
	{
		final List<RPCServiceDescription> rsds = new ArrayList<RPCServiceDescription>(); 
		RPCUtil.ForEach
		(
			new RPCUtil.ForEach()
			{
				@Override
				public void Do(int index, String methodName,String[] parameterNames, Method method)
				{
					RPCServiceDescription rsd = new RPCServiceDescription();
					
					rsd.SetName(methodName);
					rsd.SetParameters(parameterNames);
					
					rsds.add(rsd);
				}
			}
		);
		
		return rsds;
	}
}
